package com.njbw.pojo.namespace;

import com.njbw.pojo.lazyInit.ExpensiveToCreateBean;
import org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 长沙先飞信息科技有限公司<br>
 * Created with IntelliJ IDEA.<br>
 * Date:2025/7/28<br>
 * Time:14:47<br>
 * 功能描述：<br>
 *
 * @author huang hou chun
 * @since JDK 1.8 <br>
 * Copyright (c) 2023 www.csxfrj.com System Incorporated All Rights Reserved.
 */
public class NameSpaceApplication {

    private final static String LOCATION = "spring/namespace.xml";

    public static void main(String[] args) {
        testNamespace();
        testNamespaceReader();
    }

    public static void testNamespaceReader() {
        SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
        reader.loadBeanDefinitions(LOCATION);
        System.out.println(registry.getBeanDefinitionCount());
    }

    public static void testNamespace() {
        // context -> beanFactory -> alreadyCreated 来查看容器中存在的 Bean
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(LOCATION);
        ThingOneAutowireBean contextBean = context.getBean(ThingOneAutowireBean.class);
    }
}
